package 排序.冒泡排序;

public class Solution
{
    public static void BubbleSort(int [] arr)
    {
        if (arr!=null&&arr.length>0)
        {
            for (int i = 0; i < arr.length; i++)
            {
                for (int j = 0; j < arr.length - i - 1; j++)
                {
                    if (arr[j]>arr[j+1])
                    {
                        int temp=arr[j];
                        arr[j]=arr[j+1];
                        arr[j+1]=temp;
                    }
                }
            }
        }
    }

    public static void main(String[] args)
    {
        int [] a= new int[]{2,4,56,4,2,56,4,3,76};
        BubbleSort(a);
        for (int i = 0; i < a.length; i++)
        {
            System.out.println(a[i]);
        }
    }
}
